package net.homeftp.heimo;

import java.util.ArrayList;
import java.util.List;

import net.homeftp.heimo.adaptor.GridBottonAdapter;
import net.homeftp.heimo.model.Sample;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class MainActivity extends Activity {
	private GridBottonAdapter adaptor;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.grid_layout_main);
		
		List<Sample> sampleList = getSampleList();
		adaptor = new GridBottonAdapter(this,sampleList);
		
		GridView gridview = (GridView) findViewById(R.id.gridview);
		gridview.setAdapter(adaptor);
		
		final MainActivity mA = this;
		gridview.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				Sample s = adaptor.getItem(position);
				mA.startActivity(s.getIntent());
			}
		});
	}

	private ArrayList<Sample> getSampleList() {
		ArrayList<Sample> list = new ArrayList<Sample>();

		Sample s1 = new Sample(new Intent(this, ListActivity.class),"List Sample");
		list.add(s1);
		
		Sample s2 = new Sample(new Intent(this, BannerActivity.class),"AdView Sample");
		list.add(s2);
		
		Sample s3 = new Sample(new Intent(this, ChooseImageActivity.class),"Choose Image"); 
		list.add(s3);
		
		Sample s4 = new Sample(new Intent(this, PullToRefreshActivity.class),"Pull To Refresh"); 
		list.add(s4);
		
		Sample s5 = new Sample(new Intent(this, CameraActivity.class),"Camera Preview"); 
		list.add(s5);
		
		Sample s6 = new Sample(new Intent(this, WheelMenuActivity.class),"Wheel Menu"); 
		list.add(s6);
		
		
		return list;
	}
}
